# Importing Data
CHINA <- read_excel("C:/Users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "H1:H239")

# Checking the Imported Data
View(CHINA)
# Creating Time Series Data
CHINA_ts <- ts(CHINA, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
CHINA_ts
sum(is.na(CHINA_ts))
library(forecast)
CHINA_ts <- tsclean(CHINA_ts)

# Identification: Plotting the Time Series Data
plot(CHINA_ts)

# Estimating the appropriate model
CHINA_ts_model <- auto.arima(CHINA_ts)
CHINA_ts_model

# Forecasting
options(max.print=1000000)
CHINA_ts_forecast <- forecast (CHINA_ts_model, level=c(95), h=255)
plot(CHINA_ts_forecast)
CHINA_ts_forecast             

# Exporting
write.table(CHINA_ts_forecast, file="/Users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/China_TSA.csv", sep=",")
